using System;
using System.Collections;

public class Code
{
    private class ObjectService { }
    private class ObjectContext { }
    private class Employee { }
    private class Company { }
    private class Transaction { }
    private class Entity { }
    private class EntitySet { }
    private class XmlConfigLoader { }
    

    private void Methods()
    {
        // Serializing Domain Objects

        ObjectService os = new ObjectService("engines.config");
        ObjectContext oc = os.CreateObjectContext();

        Employee e1 = new Employee();
        e1.Firstname = "John";
        e1.Name = "Smith";
        e1.Salary = 2000;

        Employee e2 = new Employee();
        e1.Firstname = "Roland";
        e1.Name = "Mendel";
        e1.Salary = 3000;

        Company c = new Company();
        c.Name = "Janette Limeira";
        c.Chairman = "Alfreds";
        c.Employees.Add(e1);
        c.Employees.Add(e2);

        os.BeginTransaction();
        os.Serialize(c);
        os.CommitTransaction();

        os.BeginTransaction();
        os.Serialize(e1);
        os.Serialize(e2);
        os.CommitTransaction();

        IList employees = pm.Load(typeof(Employee));

        IList employees = pm.Load(typeof(Employee), "[Name = 'Smith']");

        foreach (Employee e in employees)
        {
            Console.WriteLine(String.Format("{0}: {1}", e.Name, e.Salary));
        }
        /*
         Mendel: 3000
         Smith: 2000
         */

        IList companies = oc.Load(typeof(Company), "[Name = 'Alfreds']");

        foreach (Company c in companies)
        {
            Console.WriteLine(c.Name);
            foreach (Employee e in c.Employees)
            {
                Console.WriteLine(e.Name);
            }
        }
        
        // Powerpoint

IPersistenceEngine pe;

// creates a first entity
Entity p1 = new Entity("Person");
p1.AddValue("Firstname", "Bill");
p1.AddValue("Lastname", "Gates");
p1.AddValue("Age", 13);

// and a second one
Entity p2 = new Entity("Person");
p2.AddValue("Firstname", "Steeve");
p2.AddValue("Lastname", "Balmer");
p2.AddValue("Age", 13);

// adds an association between the two
p1.AddValue("Partners", p2);

Transaction t = new Transaction();
t.Serialize(p1);
t.Commit(pe);


    }

public interface IPersistenceEngine
{
    EntitySet Load(string opath, string[] attributes, string orderby, int first, int max);
    EntitySet LoadWithId(string type, string[] id, string[] attributes);
    void LoadReference(IEnumerable entities, string[] references);
    object LoadScalar(string opath);
    void InitializeRepository();
    void ProcessCommands(Transaction tx);
    Model Model { get; }
}

    pe = XmlConfigLoader.LoadXmlConfig("engines.config");
}